package me.send.business.service.service;

import me.send.business.service.BaseService;
import me.send.business.service.mapper.RedMapper;
import me.send.business.service.mapper.RedtypeMapper;
import me.send.business.service.pojo.Red;
import me.send.framework.util.HelperUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RedService extends BaseService {

	@Autowired
	private RedMapper redMapper;

	@Autowired
	private RedtypeMapper redtypeMapper;

	// 测试批量 2015年6月5日17:51:16
	public int[] beach_save(int count, int popid, int redtypeid) {
		int[] results = new int[count];
		if (count > 0) {
			for (int i = 0; i < count; i++) {
				results[i] = 0;
				try {
					Red red = new Red();
					red.setMoney("10");

					red.setRedtypeid(redtypeid);
					red.setPopid(popid);
					red.setCreatetime(HelperUtil.getCurrentDate());
					red.setDescption(this.redtypeMapper.map_name_id(redtypeid));
					red.setRednumber(HelperUtil.uuid());
					this.redMapper.save(red);
					results[i] = 1;
				} catch (Exception e) {
					results[i] = 0;
				}
			}
		}
		return results;
	}

}
